package com.ruoyi.web.controller.cinema;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cinema.domain.ComboGroupGoods;
import com.ruoyi.cinema.service.IComboGroupGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐组合内商品Controller
 *
 * @author HHAOYU
 * @date 2020-12-09
 */
@RestController
@RequestMapping("/cinema/comboGroupGoods")
public class ComboGroupGoodsController extends BaseController
{
    @Autowired
    private IComboGroupGoodsService comboGroupGoodsService;

    /**
     * 查询套餐组合内商品列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComboGroupGoods comboGroupGoods)
    {
        startPage();
        List<ComboGroupGoods> list = comboGroupGoodsService.selectComboGroupGoodsList(comboGroupGoods);
        return getDataTable(list);
    }

    /**
     * 导出套餐组合内商品列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:export')")
    @Log(title = "套餐组合内商品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ComboGroupGoods comboGroupGoods)
    {
        List<ComboGroupGoods> list = comboGroupGoodsService.selectComboGroupGoodsList(comboGroupGoods);
        ExcelUtil<ComboGroupGoods> util = new ExcelUtil<ComboGroupGoods>(ComboGroupGoods.class);
        return util.exportExcel(list, "comboGroupGoods");
    }

    /**
     * 获取套餐组合内商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(comboGroupGoodsService.selectComboGroupGoodsById(id));
    }

    /**
     * 新增套餐组合内商品
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:add')")
    @Log(title = "套餐组合内商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComboGroupGoods comboGroupGoods)
    {
        return toAjax(comboGroupGoodsService.insertComboGroupGoods(comboGroupGoods));
    }

    /**
     * 修改套餐组合内商品
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:edit')")
    @Log(title = "套餐组合内商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComboGroupGoods comboGroupGoods)
    {
        return toAjax(comboGroupGoodsService.updateComboGroupGoods(comboGroupGoods));
    }

    /**
     * 删除套餐组合内商品
     */
    @PreAuthorize("@ss.hasPermi('cinema:comboGroupGoods:remove')")
    @Log(title = "套餐组合内商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(comboGroupGoodsService.deleteComboGroupGoodsByIds(ids));
    }
}
